package com.tm.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.tm.mapper.CommonMapper;

@Controller
public class ViewController {
	
	@Autowired
	private CommonMapper cMapper;
	
	/**
	 * 跳转注册
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/register", method = RequestMethod.GET)
	public String register(HttpServletRequest request, HttpServletResponse response, ModelMap model){
		String memberId = request.getParameter("memberId");
    	
    	model.addAttribute("memberId", memberId);
		return "register";
	}
	
	/**
	 * 跳转下载
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/download", method = RequestMethod.GET)
	public String download(HttpServletRequest request, HttpServletResponse response, ModelMap model){
		
		/*Map<String, String> app = cMapper.getTopApp();
    	String downloadUrl = "";
    	
    	if(app != null)
    		downloadUrl = app.get("app_url");*/
    	model.addAttribute("iosUrl", "");	
    	model.addAttribute("androidUrl", "3213");
		
		return "download";
	}
	
	/**
	 * 跳转至分享首页
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/shareIndex", method = RequestMethod.GET)
	public String shareIndex(HttpServletRequest request, HttpServletResponse response, ModelMap model){
		String memberId = request.getParameter("memberId");
    	
    	model.addAttribute("memberId", memberId);
		return "share-index";
	}
	
}
